<template>
  <view class="al">
    <form @submit="formSubmit" @reset="formReset">
		<view class="for">
			
			<view class="content">
			  <label class="lable">*原铁水成分碳含量%:</label>
			 <!-- <input
			    class="txt"
			    type="number"
			    v-model="form.cBz"
			    placeholder="请输入.."
			  /> -->
			  <text class="txt" type="number" >{{form.cBz}}</text>
			</view>
			
			<view class="content">
			  <label class="lable">*原铁水成分硅含量%:</label>
			  <!-- <input
			    class="txt"
			    type="number"
			    v-model="form.siBz"
			    placeholder="请输入.."
			  /> -->
			  <text class="txt" type="number" >{{form.siBz}}</text>
			</view>
			
			<view class="content">
			  <label class="lable">废钢碳含量%:</label>
			  <input
			    class="txt"
			    type="number"
			    v-model="form.fgChl"
			    placeholder="请输入.."
			  />
			</view>
			
			<view class="content">
			  <label class="lable">生铁碳含量%:</label>
			  <input
			    class="txt"
			    type="number"
			    v-model="form.stChl"
			    placeholder="请输入.."
			  />
			</view>
			<view class="content">
			  <label class="lable">回炉碳含量%:</label>
			  <input
			    class="txt"
			    type="number"
			    v-model="form.hllChl"
			    placeholder="请输入.."
			  />
			</view>
			
			<view class="content">
			  <label class="lable">有效成分碳含量%:</label>
			  <input
			    class="txt"
			    type="number"
			    v-model="form.cYxcfhl"
			    placeholder="请输入.."
			  />
			</view>
			<view class="content">
			  <label class="lable">原料吸收率碳含量%:</label>
			  <input
			    class="txt"
			    type="number"
			    v-model="form.cXsl"
			    placeholder="请输入.."
			  />
					</view>
					
					<view class="content">
					<label class="lable">废钢硅含量%:</label>
					  <input
					    class="txt"
					    type="number"
					    v-model="form.fgSihl"
					    placeholder="请输入.."
					  />
					</view>
					
					<view class="content">
					  <label class="lable">生铁硅含量%:</label>
					  <input
					    class="txt"
					    type="number"
					    v-model="form.stSihl"
					    placeholder="请输入.."
					  />
					</view>
					<view class="content">
					  <label class="lable">回炉硅含量%:</label>
					  <input
					    class="txt"
					    type="number"
					    v-model="form.hllSihl"
					    placeholder="请输入.."
					  />
					</view>
					
					<view class="content">
					  <label class="lable">有效成分硅含量%:</label>
					  <input
					    class="txt"
					    type="number"
					    v-model="form.siYxcfhl"
					    placeholder="请输入.."
					  />
					</view>
					<view class="content">
					  <label class="lable">原料吸收率硅含量%:</label>
					  <input
					    class="txt"
					    type="number"
					    v-model="form.siXsl"
					    placeholder="请输入.."
					  />
			</view>
			<view style="display: flex;margin-top: 1%;">
				<button form-type="submit" class="btn">保存</button>
			</view>
		</view>
      
     
    </form>
  </view>
</template>

<script>
import configService from "@/common/config.service.js";
const apiUrl = configService.apiUrl;
export default {
  data() {
    return {
      form: {
        cXsl: "",
        cYxcfhl: "",
        cBz: "",
        hllChl: "",
        stChl: "",
        fgChl: "",
		siXsl: "",
		siBz: "",
		siYxcfhl: "",
		hllSihl: "",
		stSihl: "",
		fgSihl: "",
      },
    };
  },
  mounted() {
    this.getdata();
  },
  onShow:function(e){
  	this.$verify.verify();
  },
  methods: {
    // 页面加载调取数据
    getdata() {
      uni.request({
        url: apiUrl + "/dlplbtcz/list",
        header: {
          "content-type": "application/json", //自定义请求头信息
        },
        method: "POST",
        data: {
          type: 1,
		   deptId : uni.getStorageSync("deptId")
        },
        success: (res) => {
          console.log(res);
		  if(!res.data || res.data.data.length == 0){
		  	return;
		  }
          this.form = res.data.data[0];
          if (res.statusCode === 200) {
            self.Info = res.data;
            //返回数据
          }
        },
      });
    },
    // 数据更改-提交
    formSubmit() {
		if((this.form.fgChl === null || "") || (this.form.stChl === null || "") || (this.form.hllChl === null || "")
		 || (this.form.cBz === null || "") || (this.form.cYxcfhl === null || "") || (this.form.cXsl === null || "")
		  || (this.form.fgSihl === null || "") || (this.form.stSihl === null || "") || (this.form.hllSihl === null || "")
		   || (this.form.siBz === null || "") || (this.form.siYxcfhl === null || "") || (this.form.siXsl === null || "")
		
		){
					  uni.showToast({
					  	title: '表单数据不能为空',
					  	//将值设置为 success 或者直接不用写icon这个参数
					  	// icon: 'success',
					  	//显示持续时间为 2秒
					  	duration: 2000
					  })  
		}else{
			uni.request({
			  url: apiUrl + "/dlplbtcz/edit",
			  method: "POST", //请求方式，必须为大写
			  header: {
			    "Content-Type": "application/json", //自定义请求头信息
			  },
			  data : {...this.form,...{type: 1,deptId:uni.getStorageSync("deptId")}},
			  success: (res) => {
			            if (res.statusCode == 200) {
			              uni.showToast({
			                title: "成功",
			                icon: "success",
			                duration: 1500,
			              });
			              setTimeout(() => {
			                uni.redirectTo({
			                  url: "/pages/dlplss/dlplss",
			                });
			              }, 1000);
			            } else {
			              uni.showToast({
			                title: res.data.message || "获取用户信息失败",
			                icon: "none",
			                duration: 1500,
			              });
			            }
			          },
			});
		}
	
		
      
    },
  },
};
</script>

<style>
	@import url("@/common/111.css");
</style>
